#!/usr/bin/env xonsh

from os.path import dirname,abspath,join

ROOT = dirname(abspath(join(__file__,'..')))


def main():
  cd @(ROOT)
  for i in filter(bool, $(find . -type d -name '.git').split("\n")):
    dir = abspath(join(ROOT,dirname(i)))
    print(f"\n>>> {dir}\n")
    cd @(dir)
    sync
    git checkout master
    git merge dev --allow-unrelated-histories
    gitreset
    # git branch -r -d origin/dev
    # git push origin :dev


main()

